/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.skyeye.modeling.customerized.figures;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.Polyline;
import org.eclipse.draw2d.StackLayout;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;
import org.skyeye.modeling.customerized.model.SimpleInput;

/**
 * @author danlee
 */
public class ADInputFigure extends InputFigure {
private static final Dimension SIZE = new Dimension(100, 50);
private Label label;
/**
 * Constructor for LiveOutputFigure.
 */
public ADInputFigure(String ID) {
	super();
	this.label = new Label();
	label.setText("AD"+ID);
	label.setTextAlignment(Label.LEFT);
	label.setIconTextGap(5);
	this.add(label);
}

/**
 * @see org.eclipse.draw2d.Figure#getPreferredSize(int, int)
 */
public Dimension getPreferredSize(int wHint, int hHint) {
	return SIZE;
}

/**
 * @see org.eclipse.draw2d.Figure#paintFigure(Graphics)
 */
protected void paintFigure(Graphics graphics) {
	test(graphics);
}

final int rightLineLength = 20;
final int lineWidth = 1;
private void test(Graphics graphics){
	Rectangle bound = this.getBounds().getCopy();
	final float lineInset = 1;
    final int inset1 = (int)Math.floor ( lineInset );
    
	Rectangle r = new Rectangle(bound.x + inset1,bound.y + inset1,bound.width-rightLineLength-2*inset1,bound.height-2*inset1);
	graphics.setLineStyle(SWT.BOLD);
	graphics.setLineWidth(lineWidth);
	graphics.drawRoundRectangle(r, 0, 0);
	
	graphics.drawLine(new Point(bound.x+bound.width-rightLineLength,bound.y+bound.height/2), new Point(bound.x+bound.width,bound.y+bound.height/2));
	

	((FixedConnectionAnchor)this.connectionAnchors.get(SimpleInput.TERMINAL_IN)).offsetH = bound.width;
	((FixedConnectionAnchor)this.connectionAnchors.get(SimpleInput.TERMINAL_IN)).offsetV = r.height/2;
	Rectangle tmp = new Rectangle(r.x,r.y + r.height/4  ,r.width,r.height/2);
	this.label.setBounds(tmp);
}





}
